package com.bp.village.assets.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bp.common.annotation.Log;
import com.bp.common.core.controller.BaseController;
import com.bp.common.core.domain.AjaxResult;
import com.bp.common.enums.EnumBusinessType;
import com.bp.village.assets.domain.BizVillageBuildingProof;
import com.bp.village.assets.service.IBizVillageBuildingProofService;
import com.bp.common.utils.poi.ExcelUtil;
import com.bp.common.core.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * 村级房产权证情况Controller
 * 
 * @author shaominjie
 * @date 2021-02-01
 */
@RestController
@RequestMapping("/village/proof")
public class BizVillageBuildingProofController extends BaseController {
    @Resource
    private IBizVillageBuildingProofService bizVillageBuildingProofService;

    /**
     * 查询村级房产权证情况列表
     */
    @PreAuthorize("@ss.hasPermi('village:proof:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizVillageBuildingProof bizVillageBuildingProof) {
        startPage();
        List<BizVillageBuildingProof> list = bizVillageBuildingProofService.selectList(bizVillageBuildingProof);
        return getDataTable(list);
    }
    @GetMapping("/getByBuildingId/{buildingId}")
    public AjaxResult getByBuildingId(@PathVariable Long buildingId) {
        List<BizVillageBuildingProof> list = bizVillageBuildingProofService.selectByBuildingId(buildingId);
        return AjaxResult.success(list);
    }

    /**
     * 导出村级房产权证情况列表
     */
    @PreAuthorize("@ss.hasPermi('village:proof:export')")
    @Log(title = "村级房产权证情况", businessType = EnumBusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BizVillageBuildingProof bizVillageBuildingProof) {
        List<BizVillageBuildingProof> list = bizVillageBuildingProofService.selectList(bizVillageBuildingProof);
        ExcelUtil<BizVillageBuildingProof> util = new ExcelUtil<BizVillageBuildingProof>(BizVillageBuildingProof.class);
        return util.exportExcel(list, "proof");
    }

    /**
     * 获取村级房产权证情况详细信息
     */
    @PreAuthorize("@ss.hasPermi('village:proof:query')")
    @GetMapping(value = "/{proofId}")
    public AjaxResult getInfo(@PathVariable("proofId") Long proofId) {
        return AjaxResult.success(bizVillageBuildingProofService.selectById(proofId));
    }

    /**
     * 新增村级房产权证情况
     */
    @PreAuthorize("@ss.hasPermi('village:proof:add')")
    @Log(title = "村级房产权证情况", businessType = EnumBusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizVillageBuildingProof bizVillageBuildingProof) {
        return toAjax(bizVillageBuildingProofService.insert(bizVillageBuildingProof));
    }

    /**
     * 修改村级房产权证情况
     */
    @PreAuthorize("@ss.hasPermi('village:proof:edit')")
    @Log(title = "村级房产权证情况", businessType = EnumBusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizVillageBuildingProof bizVillageBuildingProof) {
        return toAjax(bizVillageBuildingProofService.update(bizVillageBuildingProof));
    }

    /**
     * 删除村级房产权证情况
     */
    @PreAuthorize("@ss.hasPermi('village:proof:remove')")
    @Log(title = "村级房产权证情况", businessType = EnumBusinessType.DELETE)
	@DeleteMapping("/{proofIds}")
    public AjaxResult remove(@PathVariable Long[] proofIds) {
        return toAjax(bizVillageBuildingProofService.deleteByIds(proofIds));
    }
}
